package gold.digger;

import gold.vo.TreeNode;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by fanzhenyu02 on 2020/6/27.
 * common problem solver template.
 */
public class LC701 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public TreeNode insertIntoBST(TreeNode root, int val) {
            if (root == null) {
                root = new TreeNode(val);
                return root;
            }
            if (root.left == null && val < root.val) {
                root.left = new TreeNode(val);
                return root;
            }
            if (root.right == null && val > root.val) {
                root.right = new TreeNode(val);
                return root;
            }
            if (root.left != null && val < root.val) {
                insertIntoBST(root.left, val);
            }
            if (root.right != null && val > root.val) {
                insertIntoBST(root.right, val);
            }
            return root;
        }
    }

    public void run() {
        Solution solution = new Solution();
        List<Integer> list = new ArrayList<>();
        System.out.println(solution.toString());
    }

    public static void main(String[] args) throws Exception {
        LC701 an = new LC701();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
